﻿using AtlasWichita.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using AtlasWichita.Controllers;

namespace AtlasWichita.Controllers
{

    public class CustomerController : Controller
    {
        //
        // GET: /Customer/
        public ActionResult Index()
        {
            return View();
        }

        //
        // GET: /Customer/Quiz
        public ActionResult Quiz()
        {
            Quiz customerQuiz = new Quiz();
            List<Adjective> adjectiveList = new List<Adjective>();
            Customer currentCustomer = Session["CurrentCustomer"] as Customer;
            Restaurant restaurantList = new Restaurant();
            makeList(adjectiveList);
            createQuiz(customerQuiz, adjectiveList);
            createRestaurants(restaurantList);
            Session["RestaurantList"] = restaurantList;
            int questionCount = customerQuiz.QuizQuestions.Count;
            currentCustomer.customerQuiz = customerQuiz;
            customerQuiz.currentQuestion = 0;
            Session["CustomerQuiz"] = customerQuiz;
            setCustomerAdjectives(currentCustomer);
            return RedirectToAction("Age");
        }

        public ActionResult AdminQuiz()
        {
            Quiz customerQuiz = new Quiz();
            List<Adjective> adjectiveList = new List<Adjective>();
            Customer currentCustomer = Session["CurrentCustomer"] as Customer;
            Restaurant restaurantList = new Restaurant();
            makeList(adjectiveList);
            createQuiz(customerQuiz, adjectiveList);
            createRestaurants(restaurantList);
            Session["RestaurantList"] = restaurantList;
            int questionCount = customerQuiz.QuizQuestions.Count;
            currentCustomer.customerQuiz = customerQuiz;
            customerQuiz.currentQuestion = 0;
            Session["CustomerQuiz"] = customerQuiz;
            setCustomerAdjectives(currentCustomer);
            return RedirectToAction("Admin");
        }

        /*
         * Creates a view for the age questions, starting the quiz.
         */

        public ActionResult Age()
        {
            return View();
        }

        /*
         * Creates a view for the sex question, and calculates the answer for the age question.
         */

        public ActionResult Sex(String Answer)
        {
            Customer currentCustomer = Session["CurrentCustomer"] as Customer;
            if (Answer.CompareTo("15-24") == 0)
            {
                currentCustomer.addToPoints(-6, -6, 0, 6, 6, 4, 2, 0, 6, 6, -2);
            }
            else if (Answer.CompareTo("25-34") == 0)
            {
                currentCustomer.addToPoints(-2, -2, 0, 2, 2, 2, 0, 0, 2, 2, -2);
            }
            else if (Answer.CompareTo("35-44") == 0)
            {
                currentCustomer.addToPoints(0, 0, 0, 0, -2, 0, 0, 0, 0, 0, 0);
            }
            else if (Answer.CompareTo("45-54") == 0)
            {
                currentCustomer.addToPoints(0, 0, 0, 0, -2, 0, 0, 0, 0, -4, 0);
            }
            else if (Answer.CompareTo("55-64") == 0)
            {
                currentCustomer.addToPoints(2, 2, 0, -2, -6, -2, 0, 0, -2, -6, 2);
            }
            else
                currentCustomer.addToPoints(6, 6, 0, -2, -6, -4, -2, 0, -6, -6, 2);
            return View();
        }

        /*
         * Creates a view for the education question, and calculates the answer for the sex question.
         */

        public ActionResult Education(String Answer)
        {
            Customer currentCustomer = Session["CurrentCustomer"] as Customer;
            if (Answer.CompareTo("Male") == 0)
            {
                currentCustomer.addToPoints(-2, -2, -1, 1, -1, 3, 2, 1, 0, 0, -1);
            }
            else
                currentCustomer.addToPoints(2, 2, 1, -1, 1, -3, -2, -1, 0, 0, 1);
            return View();
        }

        /*
         * Creates a view for the marital status question, and calculates the answer for the education question
         */

        public ActionResult MaritalStatus(String Answer)
        {
            Customer currentCustomer = Session["CurrentCustomer"] as Customer;
            if (Answer.CompareTo("High School") == 0)
            {
                currentCustomer.addToPoints(-2, 2, -2, 6, -2, 6, -2, 0, 0, 0, -2);
            }
            else if (Answer.CompareTo("Some College") == 0)
            {
                currentCustomer.addToPoints(0, -2, 0, 2, 2, 2, 2, 0, 0, 0, 0);
            }
            else if (Answer.CompareTo("Bachelor's") == 0)
            {
                currentCustomer.addToPoints(2, -1, 2, -2, 2, -2, 2, 0, 0, 0, 2);
            }
            else
                currentCustomer.addToPoints(6, 2, 6, -6, -2, -6, -2, 0, 0, 0, -6);
            return View();
        }

        /*
         * Creates a view for the income question, and calculates the answer for the marital status question.
         */

        public ActionResult Income(String Answer)
        {
            Customer currentCustomer = Session["CurrentCustomer"] as Customer;
            if (Answer.CompareTo("Single") == 0)
            {
                currentCustomer.addToPoints(-4, -4, -4, 2, 4, 4, 4, 0, 4, 0, 0);
            }
            else if (Answer.CompareTo("Married for 0 to 5 years") == 0)
            {
                currentCustomer.addToPoints(0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0);
            }
            else if (Answer.CompareTo("Married for 5 to 20 years") == 0)
            {
                currentCustomer.addToPoints(2, 2, 2, 0, -2, -2, 0, 0, 0, 0, 0);
            }
            else
                currentCustomer.addToPoints(6, 6, 6, -2, -2, -4, -2, 0, -4, 0, 0);
            return View();
        }

        /*
         * Creates a view for the children question, and calculates the answer for the income question.
         */

        public ActionResult Children(String Answer)
        {
            Customer currentCustomer = Session["CurrentCustomer"] as Customer;
            if (Answer.CompareTo("< $30,000") == 0)
            {
                currentCustomer.addToPoints(-4, 0, 4, 6, -4, 4, -1, 4, 0, 0, -4);
            }
            else if (Answer.CompareTo("$30,000 - $50,000") == 0)
            {
                currentCustomer.addToPoints(0, 0, 0, 2, 0, 2, 1, 2, 0, 0, 0);
            }
            else if (Answer.CompareTo("$50,000 - $75,000") == 0)
            {
                currentCustomer.addToPoints(2, 0, -2, -2, 2, -2, 1, 0, 0, 0, 2);
            }
            else
                currentCustomer.addToPoints(6, 0, -6, -6, 6, -4, -1, -2, 0, 0, -6);
            return View();
        }

        /*
         * Calculates the answer for the children question, then starts the quiz
         */

        public ActionResult startQuiz(String Answer)
        {
            Customer currentCustomer = Session["CurrentCustomer"] as Customer;
            if (Answer.CompareTo("0") == 0)
            {
                currentCustomer.addToPoints(-4, -4, -4, 4, 6, 4, 4, 0, 4, 0, 0);
            }
            else if (Answer.CompareTo("1") == 0)
            {
                currentCustomer.addToPoints(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
            }
            else if (Answer.CompareTo("2") == 0)
            {
                currentCustomer.addToPoints(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
            }
            else if (Answer.CompareTo("3") == 0)
            {
                currentCustomer.addToPoints(2, 2, 2, -2, -2, -2, -2, 0, 0, 0, 0);
            }
            else
                currentCustomer.addToPoints(4, 4, 4, -2, -2, -4, -2, 0, 0, 0, 0);
            Quiz customerQuiz = Session["CustomerQuiz"] as Quiz;
            return View(customerQuiz);
        }

        /*
         * This method takes the quiz for the Customer
         */

        public ActionResult nextQuestion(String Answer)
        {
            Quiz customerQuiz = Session["CustomerQuiz"] as Quiz;
            Customer currentCustomer = Session["CurrentCustomer"] as Customer;
            string answerA = customerQuiz.QuizQuestions[customerQuiz.currentQuestion].answerA.adjective;
            string answerB = customerQuiz.QuizQuestions[customerQuiz.currentQuestion].answerB.adjective;
            if (Answer.CompareTo(answerA) == 0)
            {
                addPoints(currentCustomer, customerQuiz.QuizQuestions[customerQuiz.currentQuestion].answerA);
            }
            else
            {
                addPoints(currentCustomer, customerQuiz.QuizQuestions[customerQuiz.currentQuestion].answerB);
            }
            customerQuiz.currentQuestion++;

            // If all questions have been taken
            if (customerQuiz.currentQuestion == customerQuiz.numberOfQuestions)
                return RedirectToAction("Personality1");

            return View(customerQuiz);
        }

        public ActionResult Personality1()
        {
            return View();
        }

        public ActionResult Personality2(String Answer)
        {
            Customer currentCustomer = Session["CurrentCustomer"] as Customer;
            if (Answer.CompareTo("Vacation at a resort") == 0)
            {
                currentCustomer.addToPoints(4, 6, -4, 6, -2, -8, -4, 4, -8, 2, 6);
            }
            else
                currentCustomer.addToPoints(-4, -6, 4, -6, 2, 8, 4, -4, 8, -2, -6);
            return View();
        }

        public ActionResult Personality3(String Answer)
        {
            Customer currentCustomer = Session["CurrentCustomer"] as Customer;
            if (Answer.CompareTo("Sunday morning") == 0)
            {
                currentCustomer.addToPoints(8, 8, -2, 2, -8, -4, -6, -2, -8, -6, 4);
            }
            else
                currentCustomer.addToPoints(-8, -8, 2, -2, 8, 4, 6, 2, 8, 6, -4);
            return View();
        }

        public ActionResult QuizDone(String Answer)
        {
            Customer currentCustomer = Session["CurrentCustomer"] as Customer;
            currentCustomer.testTaken = true;
            if (Answer.CompareTo("A new dish at a new restaurant") == 0)
            {
                currentCustomer.addToPoints(-4, -6, -4, 2, 8, 0, 8, 2, 6, 6, 2);
            }
            else if (Answer.CompareTo("A new dish at a familiar restaurant") == 0)
            {
                currentCustomer.addToPoints(-2, -2, -2, 0, -2, 0, -2, 0, -2, -2, 0);
            }
            else if (Answer.CompareTo("An old dish at a familiar restaurant") == 0)
            {
                currentCustomer.addToPoints(4, 6, 4, -2, -8, 0, -8, -2, -6, -6, -2);
            }
            else
                currentCustomer.addToPoints(2, 2, 2, 0, 2, 0, 2, 0, 2, 2, 0);
            return Redirect("ComputeResults");
        }

        public ActionResult ComputeResults()
        {
            Customer currentCustomer = Session["CurrentCustomer"] as Customer;
            if (currentCustomer.testTaken == false)
            {
                return RedirectToAction("TestNotTaken");
            }
            int highest = 0, i = 0, j = 0;
            CustomerAdjective highestAdjective = new CustomerAdjective();
            List<CustomerAdjective> list = makeCustomerAdjectiveList();
            foreach (CustomerAdjective a in list)
            {
                if (Math.Abs(a.totalPoints) > highest)
                {
                    highestAdjective = a;
                    highest = Math.Abs(a.totalPoints);
                    j = i;
                }
                i++;
            }
            currentCustomer.adjective1 = highestAdjective;
            if (highestAdjective.totalPoints < 0)
                currentCustomer.highestAdjective = highestAdjective.oppositeAdjective;
            else
                currentCustomer.highestAdjective = highestAdjective.adjective;
            list.RemoveAt(j);
            i = 0;
            j = 0;
            highest = 0;
            foreach (CustomerAdjective a in list)
            {
                if (Math.Abs(a.totalPoints) > highest)
                {
                    highestAdjective = a;
                    highest = Math.Abs(a.totalPoints);
                    j = i;
                }
                i++;
            }
            currentCustomer.adjective2 = highestAdjective;
            if (highestAdjective.totalPoints < 0)
                currentCustomer.secondHighestAdjective = highestAdjective.oppositeAdjective;
            else
                currentCustomer.secondHighestAdjective = highestAdjective.adjective;
            list.RemoveAt(j);
            i = 0;
            j = 0;
            highest = 0;
            foreach (CustomerAdjective a in list)
            {
                if (Math.Abs(a.totalPoints) > highest)
                {
                    highestAdjective = a;
                    highest = Math.Abs(a.totalPoints);
                    j = i;
                }
                i++;
            }
            currentCustomer.adjective3 = highestAdjective;
            if (highestAdjective.totalPoints < 0)
                currentCustomer.thirdHighestAdjective = highestAdjective.oppositeAdjective;
            else
                currentCustomer.thirdHighestAdjective = highestAdjective.adjective;
            return RedirectToAction("ShowResults");
        }

        public ActionResult ShowResults()
        {
            return (RedirectToAction("Index", "Profile"));
        }

        public ActionResult TestNotTaken()
        {
            return View();
        }

        private List<CustomerAdjective> makeCustomerAdjectiveList()
        {
            Customer currentCustomer = Session["CurrentCustomer"] as Customer;
            List<CustomerAdjective> list = new List<CustomerAdjective>();
            list.Add(currentCustomer.Formal);
            list.Add(currentCustomer.Conformist);
            list.Add(currentCustomer.BlueCollar);
            list.Add(currentCustomer.Simple);
            list.Add(currentCustomer.Trendy);
            list.Add(currentCustomer.Gritty);
            list.Add(currentCustomer.Independent);
            list.Add(currentCustomer.Local);
            list.Add(currentCustomer.Energetic);
            list.Add(currentCustomer.Modern);
            list.Add(currentCustomer.Elegant);
            return list;
        }

        private void addPoints(Customer currentCustomer, Adjective answer)
        {
            currentCustomer.Formal.totalPoints += answer.formalValue;
            currentCustomer.Conformist.totalPoints += answer.conformistValue;
            currentCustomer.BlueCollar.totalPoints += answer.bluecollarValue;
            currentCustomer.Simple.totalPoints += answer.simpleValue;
            currentCustomer.Trendy.totalPoints += answer.trendyValue;
            currentCustomer.Gritty.totalPoints += answer.grittyValue;
            currentCustomer.Independent.totalPoints += answer.independentValue;
            currentCustomer.Local.totalPoints += answer.localValue;
            currentCustomer.Energetic.totalPoints += answer.energeticValue;
            currentCustomer.Modern.totalPoints += answer.modernValue;
            currentCustomer.Elegant.totalPoints += answer.elegantValue;
        }

        private void makeList(List<Adjective> adjectiveList)
        {
            Adjective local = new Adjective("Local", -2, -2, 6, 4, 2, 2, 6, 10, 4, 0, -2);
            adjectiveList.Add(local);
            Adjective global = new Adjective("Global", 2, 2, -6, -4, -2, -2, -6, -10, -4, 0, -2);
            adjectiveList.Add(global);
            Adjective whiteCollar = new Adjective("White-collar", 2, 4, -10, -6, 4, -6, -4, -4, -2, 2, 6);
            adjectiveList.Add(whiteCollar);
            Adjective blueCollar = new Adjective("Blue-collar", -2, -4, 10, 6, -4, 6, 4, 4, 2, -2, -6);
            adjectiveList.Add(blueCollar);
            Adjective loyal = new Adjective("Loyal", 2, 6, 2, -2, -4, -2, -10, 4, -4, -4, 2);
            adjectiveList.Add(loyal);
            Adjective independent = new Adjective("Independent", -2, -6, -2, 2, 4, 2, 10, -4, 4, 4, -2);
            adjectiveList.Add(independent);
            Adjective modern = new Adjective("Modern", -2, 0, -4, -4, 8, -6, 2, -2, 4, 10, 4);
            adjectiveList.Add(modern);
            Adjective vintage = new Adjective("Vintage", 2, 0, 4, 4, -8, 6, -2, 2, -4, -10, -4);
            adjectiveList.Add(vintage);
            Adjective urban = new Adjective("Urban", 2, -2, -4, -6, 4, -4, -2, -4, 2, 4, 4);
            adjectiveList.Add(urban);
            Adjective rural = new Adjective("Rural", -2, 2, 4, 6, -4, 4, 2, 4, -2, -4, -4);
            adjectiveList.Add(rural);
            Adjective outgoing = new Adjective("Outgoing", -4, -4, -2, 0, 4, 0, 2, 2, 6, 4, 4);
            adjectiveList.Add(outgoing);
            Adjective reserved = new Adjective("Reserved", 4, 4, 2, 0, -4, 0, -2, -2, -6, -4, -4);
            adjectiveList.Add(reserved);
            Adjective organized = new Adjective("Organized", 4, 6, -2, 2, -2, -4, -2, -2, -4, -2, 4);
            adjectiveList.Add(organized);
            Adjective spontaneous = new Adjective("Spontaneous", -4, -6, 2, -2, 2, 4, 2, 2, 4, 2, -4);
            adjectiveList.Add(spontaneous);
            Adjective formal = new Adjective("Formal", 10, 4, 0, -4, -4, -4, -4, -2, -6, -4, 4);
            adjectiveList.Add(formal);
            Adjective casual = new Adjective("Casual", -10, -4, 0, 4, 4, 4, 4, 2, 6, 4, -4);
            adjectiveList.Add(casual);
            Adjective energetic = new Adjective("Energetic", -2, -6, 2, 2, 6, 2, 4, 2, 10, 6, 4);
            adjectiveList.Add(energetic);
            Adjective relaxed = new Adjective("Relaxed", 2, 6, -2, -2, -6, -2, -4, -2, -10, -6, -4);
            adjectiveList.Add(relaxed);
            Adjective hip = new Adjective("Hip", -4, -2, -2, -2, 8, 0, 2, 2, 6, 8, 4);
            adjectiveList.Add(hip);
            Adjective traditional = new Adjective("Traditional", 4, 2, 2, 2, -8, 0, -2, -2, -6, -8, -4);
            adjectiveList.Add(traditional);
            Adjective gritty = new Adjective("Gritty", -6, -4, 6, 6, 2, 10, 6, 4, 6, -2, -6);
            adjectiveList.Add(gritty);
            Adjective upscale = new Adjective("Upscale", 6, 4, -6, -6, -2, -10, -6, -4, -6, 2, 6);
            adjectiveList.Add(upscale);
        }

        /*
         * Creates the quiz for the Customer to take
         */

        private void createQuiz(Quiz quiz, List<Adjective> adjectiveList)
        {
            int count = adjectiveList.Count, i = 0, numberOfQuestions = 0;
            while (i < count)
            {
                Question newQuestion = new Question("Which adjective describes you better?"
                    , adjectiveList[i], adjectiveList[i + 1]);
                quiz.QuizQuestions.Add(newQuestion);
                i += 2;
                numberOfQuestions++;
            }
            quiz.numberOfQuestions = numberOfQuestions;
        }

        private void setCustomerAdjectives(Customer currentCustomer)
        {
            currentCustomer.Formal = new CustomerAdjective();
            currentCustomer.Conformist = new CustomerAdjective();
            currentCustomer.BlueCollar = new CustomerAdjective();
            currentCustomer.Simple = new CustomerAdjective();
            currentCustomer.Trendy = new CustomerAdjective();
            currentCustomer.Gritty = new CustomerAdjective();
            currentCustomer.Independent = new CustomerAdjective();
            currentCustomer.Local = new CustomerAdjective();
            currentCustomer.Energetic = new CustomerAdjective();
            currentCustomer.Modern = new CustomerAdjective();
            currentCustomer.Elegant = new CustomerAdjective();
            currentCustomer.Formal.adjective = "Formal";
            currentCustomer.Conformist.adjective = "Conformist";
            currentCustomer.BlueCollar.adjective = "Blue Collar";
            currentCustomer.Simple.adjective = "Simple";
            currentCustomer.Trendy.adjective = "Trendy";
            currentCustomer.Gritty.adjective = "Gritty";
            currentCustomer.Independent.adjective = "Independent";
            currentCustomer.Local.adjective = "Local";
            currentCustomer.Energetic.adjective = "Energetic";
            currentCustomer.Modern.adjective = "Modern";
            currentCustomer.Elegant.adjective = "Elegant";
            currentCustomer.Formal.oppositeAdjective = "Casual";
            currentCustomer.Conformist.oppositeAdjective = "Rebellious";
            currentCustomer.BlueCollar.oppositeAdjective = "White Collar";
            currentCustomer.Simple.oppositeAdjective = "Sophisticated";
            currentCustomer.Trendy.oppositeAdjective = "Traditional";
            currentCustomer.Gritty.oppositeAdjective = "Refined";
            currentCustomer.Independent.oppositeAdjective = "Associative";
            currentCustomer.Local.oppositeAdjective = "Global";
            currentCustomer.Energetic.oppositeAdjective = "Relaxed";
            currentCustomer.Modern.oppositeAdjective = "Classical";
            currentCustomer.Elegant.oppositeAdjective = "Ordinary";
        }

        private void createRestaurants(Restaurant restaurantList)
        {
            Restaurant rest1 = new Restaurant("Old-Fashioned Restaurant", "788 Hott Street,\nWichita, KS 67214", "316-259-7890", "Formal", "Traditional", "Classical", 3);
            restaurantList.RestaurantList.Add(rest1);
            Restaurant rest2 = new Restaurant("Quick, Fast Burgers", "423 2nd Street,\nWichita, KS 67217", "316-555-4646", "Relaxed", "Simple", "Blue Collar", 1);
            restaurantList.RestaurantList.Add(rest2);
            Restaurant rest3 = new Restaurant("Fancy Italian Restaurant", "2507 S Douglas Ave,\nWichita, KS 67218", "316-200-2332", "Global", "Classical", "Refined", 4);
            restaurantList.RestaurantList.Add(rest3);
            Restaurant rest4 = new Restaurant("Local Pizza Place", "2629 Quiet Valley Lane,\nWichita, KS 67218", "316-100-8870", "Local", "Simple", "Gritty", 2);
            restaurantList.RestaurantList.Add(rest4);
            Restaurant rest5 = new Restaurant("Taco Supreme", "1470 Ethels Lane,\nWichita, KS 67212", "316-467-3578", "Local", "Casual", "Modern", 1);
            restaurantList.RestaurantList.Add(rest5);
            Restaurant rest6 = new Restaurant("John's Steakhouse", "3026 Glendale Avenue,\nWichita, KS 67220", "316-444-2211", "Casual", "Trendy", "Relaxed", 5);
            restaurantList.RestaurantList.Add(rest6);
            Restaurant rest7 = new Restaurant("Loud Roadhouse", "36 Godfrey Street,\nWichita, KS 67207", "316-245-7800", "Energetic", "Gritty", "Rebellious", 3);
            restaurantList.RestaurantList.Add(rest7);
            Restaurant rest8 = new Restaurant("Fancy Seafood Restaurant", "1123 N Rock Rd,\nWichita, KS 67220", "316-222-3478", "Traditional", "Global", "Ordinary", 4);
            restaurantList.RestaurantList.Add(rest8);
            Restaurant rest9 = new Restaurant("Basic Chain Restaurant", "4452 Browning Lane,\nWichita, KS 67210", "316-555-6664", "Casual", "Ordinary", "Conformist", 3);
            restaurantList.RestaurantList.Add(rest9);
            Restaurant rest10 = new Restaurant("Wichita Galaxy Subs", "1612 Brown Street,\nWichita, KS 67211", "316-978-4320", "Local", "Casual", "Ordinary", 2);
            restaurantList.RestaurantList.Add(rest10);
        }

        public ActionResult Admin()
        {
            return View();
        }

        public ActionResult selectProfile(String Answer)
        {
            Customer currentCustomer = Session["CurrentCustomer"] as Customer;
            currentCustomer.testTaken = true;
            if (Answer == "Kameron") {
                currentCustomer.addToPoints(-40, -34, 1, 16, 39, 13, 15, 28, 42, 43, 5);
                currentCustomer.testTaken = true;
                Session["CurrentCustomer"] = currentCustomer;
            }
            else if (Answer == "Tam")
            {
                currentCustomer.addToPoints(-20, 50, -20, 30, -40, -50, 25, 22, 0, 38, 15);
                currentCustomer.testTaken = true;
                Session["CurrentCustomer"] = currentCustomer;
            }
            else if (Answer == "Fancy Businessman")
            {
                currentCustomer.addToPoints(40, 30, -40, -15, 26, -17, 39, -25, 0, -10, 21);
            }
            else if (Answer == "Broke College Student")
            {
                currentCustomer.addToPoints(-20, -40, 0, -20, 40, 0, 50, 10, 33, 25, 5);
            }
            else if (Answer == "Middle-class Surburban Father")
            {
                currentCustomer.addToPoints(15, 25, 40, 30, 5, 23, 2, 10, 5, 29, -15);
            }
            Session["CurrentCustomer"] = currentCustomer;
            return RedirectToAction("ComputeResults");            
        }
    }
}
